<?php

require_once 'Zend/Filter/Interface.php';


class App_Filter_Encrypt implements Zend_Filter_Interface {
    
    protected $_function;

    public function __construct($function = null) {
        if(in_array($type, array('md5', 'sha1'))) {
           $this->_function = $function;
        }
    }

    public function getFunction() {
        return $this->_function;
    }

    
    public function setFunction($function) {
        $this->_function = $function;
        return $this;
    }

    public function filter($value) {
        if (null === $this->_function) {
            return md5((string)$value);
        } else {
            if(function_exists($this->_function)) {
               return $this->_function((string) $value);
            }
        }
    }
    
}
